package com.elective.courseselect.controller;

import com.elective.courseselect.entity.ScheduleEntity;
import com.elective.courseselect.service.ScheduleService;
import com.elective.courseselect.utils.R;
import com.elective.status.StatusCode;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author lee
 * @date 2021年10月24日 12:10
 */
@RestController
@RequestMapping("courseselect/schedule")
@CrossOrigin(origins = "*",maxAge = 3600)
public class ScheduleController {

    @Autowired
    ScheduleService scheduleService;

    /**
     * 查询选课时间段
     */
    @ApiOperation("查询选课时间段")
    @GetMapping("/searchSchedule")
    public R searchSchedule(){
        ScheduleEntity scheduleEntity = scheduleService.searchSchedule();
        return R.ok(StatusCode.OK, "查询选课时间段成功").put("data", scheduleEntity);
    }

    /**
     * 查询选课时间段
     */
    @ApiOperation("修改选课时间段")
    @PostMapping("/updateSchedule")
    public R updateSchedule(@RequestBody ScheduleEntity scheduleEntity){
        return scheduleService.updateSchedule(scheduleEntity);
    }


    /**
     * add选课时间段
     */
    @ApiOperation("增加选课时间段")
    @PostMapping("/addSchedule")
    public R addSchedule(@RequestBody ScheduleEntity scheduleEntity){
        return scheduleService.addSchedule(scheduleEntity);
    }

}
